BIN               := mi-pap
CXXFLAGS          := -O3 -g

CUDA_INSTALL_PATH ?= /usr/local/cuda
CUDA_SDK_PATH ?= /opt/share/NVIDIA_GPU_Computing_SDK

NVCC ?= nvcc
INCD = -I"$(CUDA_SDK_PATH)/C/common/inc" -I"$(CUDA_INSTALL_PATH)/include" -I"./"
LIBS = -lcuda -L"$(CUDA_INSTALL_PATH)/lib64" -lcudart -lcublas -lcufft -L"$(CUDA_SDK_PATH)/C/common/lib" $(CUDA_SDK_PATH)/C/lib/libcutil$(LIBSUFFIX).a -lstdc++ -lpthread
NVCCFLAGS := --ptxas-options=-v -O3 -G -g -lcuda -lcudart


# files
CPP_SOURCES := main.cpp
CU_SOURCES := bitonicsort.cu \
		evenoddmergesort.cu \
		shearsort.cu
HEADERS := sortingalgorithms.h
CPP_OBJS := $(patsubst %.cpp, %.o, $(CPP_SOURCES))
CU_OBJS := $(patsubst %.cu, %.cu_o, $(CU_SOURCES))

%.cu_o : %.cu
	$(NVCC) -c $(NVCCFLAGS) $(INCD) -o $@ $<

%.o: %.cpp
	$(CXX) -c $(CXXFLAGS) $(INCD) -o $@ $<

$(BIN): $(CPP_OBJS) $(CU_OBJS)
	$(CXX) -lcudart -o $(BIN) $(CU_OBJS) $(CPP_OBJS) $(INCD) -L/usr/local/cuda/lib64 -lcudart

clean:
	rm -f $(BIN) *.o *.cu_o
